#include <iostream>
#include <cstring>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/syscall.h>

void* Routine(void*)
{
  while(true){
    pthread_t self = pthread_self();
    //pid_t tid = gettid();
    pid_t tid = syscall(SYS_gettid);
    printf("thread[%p]->pid:%d tid:%d\n", (int*)self, getpid(), (int)tid);
    sleep(2);
  }
}

int main()
{
  while(true){
    pthread_t tid;
    int ret;
    if((ret = pthread_create(&tid, nullptr, Routine, nullptr)) != 0){
      fprintf(stderr, "pthread_create : %s\n", strerror(ret));
    }
    sleep(2);
  }
  return 0;
}
